package cn.hairui.blog.controller;

import cn.hairui.blog.config.WebLog;
import cn.hairui.blog.constant.PubConstant;
import cn.hairui.blog.model.WebInfo;
import cn.hairui.blog.service.WebInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author laoganbu
 * @date: 2019/2/25 17:37
 */
@Controller
public class DefaultViewController {
    @Autowired
    private WebInfoService webInfoService;

    @RequestMapping(value = "/index")
    public String foreIndexPage() {
        return "redirect:/";
    }

    @RequestMapping(value = "/permissions")
    @WebLog(description = "该用户操作权限不足")
    public String permissions() {
        return "404";
    }


    @RequestMapping(value = "/test")
    public String test() {
        return "test";
    }

    @RequestMapping(value = "/register")
    public String register(HttpServletRequest request, Model model) {
        WebInfo webInfo = webInfoService.find(PubConstant.MY_INFO_ID);
        model.addAttribute("webinfo", webInfo);
        return "register";
    }
}